package model

import (
	"time"
)

type ShortLink struct {
	Base
	Id            uint      `gorm:"clprimary_key"`
	Domain        string    `gorm:"type:varchar(255);comment:域名"`
	ShortUri      string    `gorm:"type:varchar(255);uniqueIndex;comment:短链接"`
	FullShortUrl  string    `gorm:"type:varchar(255);uniqueIndex;comment:完整短链接"`
	OriginUrl     string    `gorm:"type:text;not null;comment:原始链接"`
	ClickNum      int       `gorm:"default:0;comment:点击量"`
	Gid           string    `gorm:"type:varchar(32);index;comment:分组标识"`
	EnableStatus  uint8     `gorm:"type:tinyint(1);default:0;comment:启用标识 0：启用 1：未启用"`
	CreatedType   uint8     `gorm:"type:tinyint(1);comment:创建类型 0：接口创建 1：控制台创建"`
	ValidDateType uint8     `gorm:"type:tinyint(1);default:0;comment:有效期类型 0：永久有效 1：自定义"`
	ValidDate     time.Time `gorm:"comment:有效期"`
	Describe      string    `gorm:"column:describe;type:text;comment:描述"` // 解决 MySQL 保留字冲突 [7](@ref)
	Favicon       string    `gorm:"type:varchar(255);comment:网站标识"`
	TotalPv       int       `gorm:"default:0;comment:历史PV"`
	TotalUv       int       `gorm:"default:0;comment:历史UV"`
	TotalUip      int       `gorm:"default:0;comment:历史UIP"`
	TodayPv       int       `gorm:"-;comment:今日PV"` // 不持久化到数据库 [8](@ref)
	TodayUv       int       `gorm:"-;comment:今日UV"`
	TodayUip      int       `gorm:"-;comment:今日UIP"`
	DelTime       int64     `gorm:"comment:删除时间"`
}

func (s *ShortLink) TableName() string {
	return "t_link"
}
